package olga.gorbatiuk.perdep.sorting.arrayfiller.impl;

import java.util.Arrays;

import olga.gorbatiuk.perdep.sorting.arrayfiller.AbstractArrayFiller;
import olga.gorbatiuk.perdep.sorting.arrayfiller.ArrayFiller;

/**
 * @author Olga Gorbatiuk
 */
public class SortedArrayDesc extends AbstractArrayFiller implements ArrayFiller {

    /**
     * @see
     * olga.gorbatiuk.perdep.sorting.arrayfiller.ArrayFiller#getFilledArray(int,
     * int, int)
     */
    @Override
    public int[] getFilledArray(int min, int max, int size) {
        int[] array = getRandomlyFilledArray(min, max, size);
        Arrays.sort(array);
        int[] revertedArray = revertArray(array);
        return revertedArray;
    }

    private int[] revertArray(int[] array) {
        int length = array.length;
        for (int i = 0; i < length / 2; i++) {
            int temp = array[i];
            array[i] = array[length - i - 1];
            array[length - i - 1] = temp;
        }
        return array;
    }
}
